package com.hamizhong.iflowers.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.hamizhong.iflowers.common.exception.MyServiceException;
import com.hamizhong.iflowers.db.dao.hibernate.ITestDao;
import com.hamizhong.iflowers.db.entity.Test;
import com.hamizhong.iflowers.service.ITestService;
import com.hamizhong.iflowers.service.base.MyBaseService;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.TestObjectVO;
import com.hamizhong.iflowers.web.vo.TestVO;

public class TestServiceImpl extends MyBaseService implements ITestService {

	private ITestDao iTestDao;
	
	public ITestDao getiTestDao() {
		return iTestDao;
	}
	public void setiTestDao(ITestDao iTestDao) {
		this.iTestDao = iTestDao;
	}

	public IOPResultDto doQueryTestAll() {
		IOPResultDto<TestObjectVO> objDto = new IOPResultDto<TestObjectVO>();
		List<TestVO> testVOList = new ArrayList<TestVO>();
		TestVO testVO = null;
		List<Test> testList = iTestDao.findAll();
		for (Test test : testList) {
			testVO = new TestVO();
			try {
				BeanUtils.copyProperties(testVO, test);
				testVOList.add(testVO);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		TestObjectVO testObjectVO = new TestObjectVO();
		testObjectVO.setTestVOList(testVOList);
		objDto.addToResultList(testObjectVO);
		objDto.setSuccess(true);
		//throw new MyServiceException("my service exception!");
		return objDto;
	}
	
}
